package com.maidou.qiantai.service.impl;

import com.maidou.qiantai.domain.SpuImage;
import com.maidou.qiantai.mapper.SpuImageMapper;
import com.maidou.qiantai.service.ISpuImageService;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商品图集Service业务层处理
 * 
 * @author maidou
 * @date 2024-03-13
 */
@Service
public class SpuImageServiceImpl implements ISpuImageService 
{
    @Resource
    private SpuImageMapper spuImageMapper;

    /**
     * 查询商品图集
     * 
     * @param id 商品图集主键
     * @return 商品图集
     */
    @Override
    public SpuImage selectSpuImageById(Long id)
    {
        return spuImageMapper.selectSpuImageById(id);
    }

    /**
     * 查询商品图集列表
     * 
     * @param spuImage 商品图集
     * @return 商品图集
     */
    @Override
    public List<SpuImage> selectSpuImageList(SpuImage spuImage)
    {
        return spuImageMapper.selectSpuImageList(spuImage);
    }

    /**
     * 新增商品图集
     * 
     * @param spuImage 商品图集
     * @return 结果
     */
    @Override
    public int insertSpuImage(SpuImage spuImage)
    {
        spuImage.setCreateTime(DateUtils.getNowDate());
        return spuImageMapper.insertSpuImage(spuImage);
    }

    /**
     * 修改商品图集
     * 
     * @param spuImage 商品图集
     * @return 结果
     */
    @Override
    public int updateSpuImage(SpuImage spuImage)
    {
        spuImage.setUpdateTime(DateUtils.getNowDate());
        return spuImageMapper.updateSpuImage(spuImage);
    }

    /**
     * 批量删除商品图集
     * 
     * @param ids 需要删除的商品图集主键
     * @return 结果
     */
    @Override
    public int deleteSpuImageByIds(Long[] ids)
    {
        return spuImageMapper.deleteSpuImageByIds(ids);
    }

    /**
     * 删除商品图集信息
     * 
     * @param id 商品图集主键
     * @return 结果
     */
    @Override
    public int deleteSpuImageById(Long id)
    {
        return spuImageMapper.deleteSpuImageById(id);
    }

    /**
     * 删除图集
     * @param spuId
     * @param i
     * @return
     */
    @Override
    public Integer deleteSpuImageBySpuIdAndType(Long spuId, Integer i) {
        return spuImageMapper.deleteSpuImageBySpuIdAndType(spuId,i);
    }

    /**
     * 获取首页广告
     * @return
     */
//    @Override
//    public List<AdvertisingVo> selectSpuImageAdvertisingList() {
//        SpuImage spuImage = new SpuImage();
//        spuImage.setType(SpuConstant.SpuImageEnum.ADVERTISING.type);
//        List<SpuImage> spuImages = spuImageMapper.selectSpuImageList(spuImage);
//        List<AdvertisingVo> collect = spuImages.stream().map(item -> {
//            AdvertisingVo advertisingVo = new AdvertisingVo();
//            BeanUtils.copyProperties(item, advertisingVo);
//            return advertisingVo;
//        }).collect(Collectors.toList());
//        return collect;
//    }
}
